﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace Bll
{
    public class UserAuthorizeAttribute : AuthorizeAttribute
    {
        private byte UserPageLevel;

        /// <summary>
        /// 初始函数
        /// </summary>
        /// <param name="powerstr"></param>
        public UserAuthorizeAttribute(byte UserPageLevel = 1)
        {
            this.UserPageLevel = UserPageLevel;
        }

        private static UserInfo current = UserInfo.Instance;

        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            //            return true;
            if (httpContext == null)
                throw new ArgumentNullException("httpContext");
            if (current.IsAuthenticated)
            {
                httpContext.Response.Redirect("~/User/UserCol/Login");
                return false;
            }
            return true;
        }

    }
}